package com.tolbahady.android.game;

import java.util.*;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class PlayerslistAdapter extends ArrayAdapter<Player> {
	public PlayerslistAdapter(Context context, int textViewResourceId,
			List<Player> objects) {
		super(context, textViewResourceId, objects);
		this.players = objects;
	}



	List<Player> players;
	
	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
        if (v == null) {
            LayoutInflater vi = 
            	(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.player_row, null);
        }
        Player o = players.get(position);
        if (o != null) {
                TextView pn = (TextView) v.findViewById(R.id.player_name);
                if (pn != null) {
                	pn.setText( o.getName());                            }
        }
        return v;
	}	
}
